﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Stone
{
    public partial class FormMain : Form
    {
        //Gps
        public GPSHandler GpsHandler;

        public FormMain()
        {
            InitializeComponent();

            Settings.LoadSettings();
            //GPS_comboBox_ComPort.SelectedItem = Settings.GPS_ComPort;
            //GPS_comboBox_Baudrate.SelectedItem = Settings.GPS_ComPort_Baudrate;

            //GpsHandler = new GPSHandler(this);
            //GpsHandler.NewGPSFix += new GPSHandler.NewGPSFixHandler(this.GPSEventHandler);  

            MessageBox.Show("sdfgsdf");

            //GpsHandler.Start(Settings.GPS_ComPort, int.Parse(Settings.GPS_ComPort_Baudrate));
        }

        private void GPSEventHandler(object sender, GPSHandler.GPSEventArgs e)
        {
            ReceiveNMEA(GpsHandler, e);            
        }
        public void ReceiveNMEA(GPSHandler GpsHandler, GPSHandler.GPSEventArgs e)
        {
            switch (e.TypeOfEvent)
            {
                case GPSEventType.TimeOut:



                    break;

                case GPSEventType.GPRMC:  //Recommended minimum specific GPS/Transit data

                    label_GPRMC.Text = "" + GpsHandler.GPRMC.Position.Latitude;

                    if (GpsHandler.HasGPSFix) //Is a GPS fix available?
                    {
                        //osmMap.CAR_timeOfFix = GpsHandler.GPRMC.TimeOfFix;
                        //osmMap.CAR_course = GpsHandler.GPRMC.Course;

                        float Lon = (float)GpsHandler.GPRMC.Position.Longitude;
                        float Lat = (float)GpsHandler.GPRMC.Position.Latitude;

                        //osmMap.SetCarPosition(new PointF(Lon, Lat));

                        //osmMap.CAR_speed = GpsHandler.GPRMC.Speed;
                    }
                    break;

                case GPSEventType.GPGSV:
                    //satellites = GpsHandler.GPGSV.Satellites;
                    //visibleSatellites = GpsHandler.GPGSV.SatsInView;
                    break;
            }
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            

            
        }
    }
}
